const app = getApp();
var url = app.data.url;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    desk: [],
    tips: "提示:选择房间或餐台后请点击锁定!",
    value: "",
    orderId: ""
  },
  onLoad: function (options) {
    let _that = this;
    _that.setData({
      orderId: options.orderId
    }) 
    wx.request({
      url: url + '/OrderApi/selectPreOrderByOrderId',
      data: { orderId: options.orderId },
      method: 'POST',
      header: { 'content-type': 'application/x-www-form-urlencoded' },
      success: function (res) {
        if (res.data.code == 200) {
          _that.setData({
            value : res.data.data
          })
        } else {
          wx.showToast({
            title: '保存备注失败!',
            icon: "none",
            duration: 2000
          })
        }

      },
      fail: function (res) {
        console.info('submit fail');
      },
      complete: function (res) {
        console.info('submit complete');
      }
    })
  },
  changeVal: function (e) {
    let _that = this;
    _that.setData({
      value : e.detail
    })
  },
  submit: function(e){
    let _that = this;
    let mark = _that.data.value;
    console.log(mark);
    let orderId = _that.data.orderId;
    wx.request({
      url: url + '/OrderApi/updateMarkByOrderId',
      data: { orderId: orderId, mark: mark },
      method: 'POST',
      header: { 'content-type': 'application/x-www-form-urlencoded' },
      success: function (res) {
        if (res.data.code == 200) {
          wx.showToast({
            title: '保存成功!',
            icon: "success",
            duration: 2000
          })
        } else {
          wx.showToast({
            title: '保存备注失败!',
            icon: "none",
            duration: 2000
          })
        }

      },
      fail: function (res) {
        console.info('submit fail');
      },
      complete: function (res) {
        console.info('submit complete');
      }
    })
    

  },
  /**
       * 用户点击右上角分享
       */
  onShareAppMessage: function () {
  }
  
  
})